package rabbit.topic;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/11/7 16:18
 */

public class TestMq {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.10.66");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("root");
        connectionFactory.setPassword("root");
        connectionFactory.setVirtualHost("OuterHost");
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare("testexchange", BuiltinExchangeType.TOPIC, true);
        for (int i = 0; i < 10000; i++)
            channel.basicPublish("testexchange", "testtopic", null, "{\"name\":\"sjw\"}".getBytes("UTF-8"));
        channel.close();
        System.out.println("end");
    }
}
